﻿#include "MapPage.h"
MapPage::MapPage(ROOM_NUMBER position) :position(position) {
	for (int i = 0; i < 6; i++) {
		heroPositon[i] = ' ';
	}
	heroPositon[position] = '*';
}

void MapPage::drawPage(Hero& hero) {
	system("cls");
	system("color 06");
	cout << "                                                       " << endl;
	cout << "		*~~~~~~~~*          *~~~~~~~~*           *~~~~~~~~*" << endl;
	cout << "		*        *          *        *           *        *" << endl;
	cout << "		*神隐之地*   ←———→  * 峦月镜 *  ←———→    * 紫光阁 *" << endl;
	cout << "		*   " << heroPositon[5] << "    *          *   " << heroPositon[4] << "    *           *   " << heroPositon[3] << "    *" << endl;
	cout << "		*        *          *        *           *        *" << endl;
	cout << "		*        *          *        *           *        *" << endl;
	cout << "		 ~~~~~~~~            ~~~~~~~~             ~~~↑~~~ " << endl;
	cout << "		                                             ↓    " << endl;
	cout << "		                     *~~~~~~~~*          *~~~~~~~~*" << endl;
	cout << "		                     *        *          *        *" << endl;
	cout << "		                     *落日峡谷*  ←———→   * 拜月教 *" << endl;
	cout << "		                     *   " << heroPositon[1] << "    *          *   " << heroPositon[2] << "    *" << endl;
	cout << "		                     *        *          *        *" << endl;
	cout << "		                     *        *          *        *" << endl;
	cout << "		                      ~~~↑~~~            ~~~~~~~~ " << endl;
	cout << "		                         ↓                       " << endl;
	cout << "		                     *~~~~~~~~*                   " << endl;
	cout << "		                     *        *                   " << endl;
	cout << "		                     * 清水镇 *                   " << endl;
	cout << "		                     *   " << heroPositon[0] << "    *        " << endl;
	cout << "		                     *        *                   " << endl;
	cout << "		                     *        *                   " << endl;
	cout << "		                      ~~~↑~~~                    " << endl;
	cout << "		                         ↑                       " << endl;
	cout << "		                         ↑                       " << endl;
	cout << "		                       重启之路                 " << endl;

	cout << "您现在的位置为" << roomName[position] << endl;


}

void MapPage::updatePage(Hero& hero) {
	controlPage(hero);
	for (int i = 0; i < 6; i++) {
		heroPositon[i] = ' ';
	}
	heroPositon[position] = '*';
}

void MapPage::controlPage(Hero& hero) {
	char ch = 'c';
	switch (position)
	{
	case QING:
		cout << "你可以输入 w前往落日峡谷, c关闭地图" << endl;
		cin >> ch;
		if (ch == 'w') {
			position = LUO;
		}
		else if (ch == 'c') {
			isQuit = true;
		}

		break;

	case LUO:
		cout << "你可以输入 d前往拜月教，w前往峦月镜，s前往清水镇，c关闭地图" << endl;
		cin >> ch;
		if (ch == 'd') {
			position = BAI;
		}
		else if (ch == 'w') {
			position = LUAN;
		}
		else if (ch == 's') {
			position = QING;
		}
		else if (ch == 'c') {
			isQuit = true;
		}
		break;

	case BAI:
		cout << "你可以输入 a前往落日峡谷，输入w前往紫光阁，c关闭地图" << endl;
		cin >> ch;
		if (ch == 'a') {
			position = LUO;
		}
		else if (ch == 'w') {
			position = ZI;
		}
		else if (ch == 'c') {
			isQuit = true;
		}
		break;
	case LUAN:
		cout << "你可以输入 d前往紫光阁，输入a前往神隐之地，c关闭地图" << endl;
		cin >> ch;
		if (ch == 'd') {
			position = ZI;
		}
		else if (ch == 'a') {
			position = SHEN;
		}
		else if (ch == 'c') {
			isQuit = true;
		}
		break;
	case ZI:
		cout << "你可以输入 a前往峦月镜，输入s前往拜月教，c关闭地图" << endl;
		cin >> ch;
		if (ch == 'a') {
			position = LUAN;
		}
		else if (ch == 's') {
			position = BAI;
		}
		else if (ch == 'c') {
			isQuit = true;
		}
		break;
	case SHEN:
		cout << "你可以输入 d前往峦月镜，c关闭地图" << endl;
		cin >> ch;
		if (ch == 'd') {
			position = LUAN;
		}
		else if (ch == 'c') {
			isQuit = true;
		}
		break;
	default:
		break;
	}
}

int MapPage::get_position()const {
	return position;
}

bool MapPage::isquitPage(Hero& hero) {
	return isQuit;
}
void MapPage::loadPage() {

}